﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Usuarios.aspx.cs" Inherits="ent_pm.Usuarios.Usuarios" %>

<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<%@ Register Src="wucUsuarios.ascx" TagName="wucUsuarios" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <ext:Store runat="server" ID="StoreUsuario">
        <Reader>
            <ext:JsonReader ReaderID="Id">
                <Fields>
                    <ext:RecordField Name="Id" />
                    <ext:RecordField Name="Nombre" />
                    <ext:RecordField Name="Apellido" />
                    <ext:RecordField Name="Usuario" />
                    <ext:RecordField Name="Rol" />
                    <ext:RecordField Name="Email" />
                    <ext:RecordField Name="Telefono" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store runat="server" ID="StoreRol">
        <Reader>
            <ext:JsonReader ReaderID="Key">
                <Fields>
                    <ext:RecordField Name="Key">
                    </ext:RecordField>
                    <ext:RecordField Name="Value">
                    </ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:ScriptManager runat="server" Theme="Gray">
    </ext:ScriptManager>
    <ext:Panel ID="Panel1" BodyStyle="padding:15px;background-color:#E7E4DD;" runat="server"
        AutoHeight="true">
        <Body>
            <ext:Panel ID="Panel2" runat="server" BodyStyle="background-color:Transparent;" ButtonAlign="Center">
                <Body>
                    <ext:ColumnLayout ID="ColumnLayout1" runat="server">
                        <ext:LayoutColumn ColumnWidth=".5">
                            <ext:Panel ID="Panel3" runat="server" Border="false" Header="false" BodyStyle="padding:10px;background-color:Transparent;">
                                <Body>
                                    <ext:FormLayout ID="FormLayout1" runat="server" LabelAlign="Left" LabelWidth="70">
                                        <ext:Anchor Horizontal="95%">
                                            <ext:ComboBox Editable="false" FieldLabel="Rol" ID="cbxRol" StoreID="StoreRol" runat="server" DisplayField="Value"
                                                ValueField="Key" TypeAhead="true" ForceSelection="true" TriggerAction="All" Grow="true"
                                                GrowMax="300" EmptyText="Todos" SelectOnFocus="true" AutoDataBind="True">
                                                <Triggers>
                                                    <ext:FieldTrigger Icon="Clear" HideTrigger="true" />
                                                </Triggers>
                                                <Listeners>
                                                    <Select Handler="this.triggers[0].show();" />
                                                    <BeforeQuery Handler="this.triggers[0][ this.getRawValue().toString().length == 0 ? 'hide' : 'show']();" />
                                                    <TriggerClick Handler="if(index == 0) { this.clearValue(); this.triggers[0].hide(); }" />
                                                </Listeners>
                                            </ext:ComboBox>
                                        </ext:Anchor>
                                    </ext:FormLayout>
                                </Body>
                            </ext:Panel>
                        </ext:LayoutColumn>
                        <ext:LayoutColumn ColumnWidth=".5">
                            <ext:Panel ID="Panel4" runat="server" Border="false" BodyStyle="padding:10px;background-color:Transparent;">
                                <Body>
                                    <ext:FormLayout ID="FormLayout2" LabelSeparator=":" runat="server" LabelAlign="Left"
                                        LabelWidth="65">
                                        <ext:Anchor Horizontal="95%">
                                            <ext:TextField FieldLabel="Nombre" ID="txtNombreUsuario" runat="server" />
                                        </ext:Anchor>
                                    </ext:FormLayout>
                                </Body>
                            </ext:Panel>
                        </ext:LayoutColumn>
                    </ext:ColumnLayout>
                </Body>
                <Buttons>
                    <ext:Button runat="server" ID="btnBuscar" Text="Buscar" Icon="Find">
                        <AjaxEvents>
                            <Click OnEvent="btnBuscar_Click">
                                <EventMask ShowMask="true" />
                            </Click>
                        </AjaxEvents>
                    </ext:Button>
                </Buttons>
            </ext:Panel>
        </Body>
    </ext:Panel>
    <ext:GridPanel ID="GridPanelUsuarios" runat="server" StoreID="StoreUsuario" StripeRows="true"
        AutoWidth="true" AutoHeight="true" Title="Listado de Usuarios">
        <TopBar>
            <ext:Toolbar runat="server">
                <Items>
                    <ext:Button runat="server" ID="btnNuevo" Text="Nuevo">
                        <AjaxEvents>
                            <Click OnEvent="btnNuevo_Click">
                            <ExtraParams>
                            <ext:Parameter Name="Operacion" Value="Nuevo" Mode="Value"></ext:Parameter>
                            </ExtraParams>
                            </Click>
                        </AjaxEvents>
                    </ext:Button>
                </Items>
            </ext:Toolbar>
        </TopBar>
        <ColumnModel ID="ColumnModel1" runat="server">
            <Columns>
                <ext:Column ColumnID="Nombre" Header="Nombre" Width="180" Sortable="true"
                    DataIndex="Nombre" />
                <ext:Column Header="Apellido" Width="180" Sortable="true" DataIndex="Apellido" />
                <ext:Column Header="Usuario" Width="120" Sortable="true" DataIndex="Usuario" />
                <ext:Column DataIndex="Rol" Header="Rol" Width="140" />
                <ext:Column Header="Telefono" Width="100" Sortable="true" DataIndex="Telefono" />
                <ext:Column Header="Email" Width="100" Sortable="true" DataIndex="Email" />
                <ext:CommandColumn Header="Editar" Width="60">
                    <Commands>
                        <ext:GridCommand CommandName="Editar" Text="Editar" Icon="ApplicationEdit" ToolTip-Text="Editar datos del usuario">
                        </ext:GridCommand>
                    </Commands>
                </ext:CommandColumn>
            </Columns>
        </ColumnModel>
        <AjaxEvents>
            <Command OnEvent="command_Click">
                <ExtraParams>
                    <ext:Parameter Name="Id" Value="record.data.Id" Mode="Raw" />
                    <ext:Parameter Name="Operacion" Value="Editar" Mode="Value" />
                </ExtraParams>
            </Command>
        </AjaxEvents>
        <SelectionModel>
            <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true">
            </ext:RowSelectionModel>
        </SelectionModel>
    </ext:GridPanel>
    <uc1:wucUsuarios runat="server" ID="wucUsuarios1" />
    </form>
</body>
</html>
